﻿@model Ingenuity.Web.Models.ProcessInfo

@{
    ViewData["Title"] = "CreateProcessInfo";
}

<h2>新增工序安排</h2>

<h4>工序信息</h4>
<hr />
<div class="row">
    <div class="col-md-4">
        <form asp-action="CreateProcessInfo">
            <div asp-validation-summary="ModelOnly" class="text-danger"></div>
            <input type="hidden" asp-for="MaterialInfoId" />
            <div class="form-group">
                <label asp-for="WorkName" class="control-label">工序名称</label>
                <input asp-for="WorkName" class="form-control" />
                <span asp-validation-for="WorkName" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="EquipInfoId" class="control-label">设备号</label>
                <input type="number" readonly asp-for="EquipInfoId" class="form-control" /><br />
                <button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#myModal">选择设备</button>
            </div>
            <div class="form-group">
                <input type="submit" value="新增" class="btn btn-default" />
            </div>
        </form>
    </div>
</div>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-body">
                <table class="table table-striped">
                    <tr>
                        <th></th>
                        <th>设备编号</th>
                        <th>设备名称</th>
                        <th>车间机位</th>
                        <th>工作情况</th>
                        <th>运行状态</th>
                        <th>创建时间</th>
                    </tr>
                    @foreach (var item in ViewBag.EquipInfoList)
                    {
                        <tr>
                            <td><input type="radio" value="@item.Id" name="equip" /></td>
                            <td>@item.EquipNumber</td>
                            <td>@item.Name</td>
                            <td>@item.Site</td>
                            <td>@item.WorkSituation</td>
                            <td>@item.OperateSituation</td>
                            <td>@item.CreateDate</td>
                        </tr>
                    }
                </table>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" id="save" class="btn btn-primary">保存</button>
            </div>
        </div>
    </div>
</div>

<div>
    <a asp-action="OrderList" asp-controller="Order">返回订单列表</a>
</div>

@section scripts{
    <script type="text/javascript">
        $(function () {
            $("input[name='equip']").eq(0).attr("checked", true);
            $("#save").click(function () {
                var equipId = $("input[name='equip']:checked").val();
                if (equipId > 0) {
                    $("#EquipInfoId").val(equipId);
                }
                $('#myModal').modal('hide');
            });
        });
    </script>
}

